package com.yunfangdata.web.controller;

import com.yunfangdata.domain.RecruitPlanDetail;
import com.yunfangdata.query.ApplicantQueryObject;
import com.yunfangdata.query.QueryObject;
import com.yunfangdata.query.RecruitDetailQueryObject;
import com.yunfangdata.service.IRecruitPlanDetailService;
import com.yunfangdata.util.JsonResult;
import com.yunfangdata.util.PageResult;
import com.yunfangdata.util.PermissionName;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("recruitDetail")
public class RecruitPlanDetailController {


    @Autowired
    private IRecruitPlanDetailService service;


    @RequiresPermissions("recruitDetail:list")
    @PermissionName("招聘计划明细列表")
    @RequestMapping("list")
    @ResponseBody
    public PageResult list(QueryObject qo) {

        return  service.query(qo);
    }



    @RequiresPermissions("recruitDetail:list")
    @PermissionName("招聘计划明细列表")
    @RequestMapping("queryByRecruit")
    @ResponseBody
    public PageResult queryByRecruit(RecruitDetailQueryObject rqo) {

        return  service.queryByRecruit(rqo);
    }

    @RequiresPermissions("recruitDetail:save")
    @PermissionName("招聘计划明细保存")
    @RequestMapping("save")
    @ResponseBody
    public JsonResult save(RecruitPlanDetail detail) {
        JsonResult js = new JsonResult();
        try {
            service.save(detail);
        } catch (Exception e) {
            e.printStackTrace();
            js = new JsonResult("保存失败");
        }
        return js;
    }



    @RequiresPermissions("recruitDetail:delete")
    @PermissionName("招聘计划详细列表删除")
    @RequestMapping("delete")
    @ResponseBody
    public JsonResult delete(Long id) {
        JsonResult js =new JsonResult();
        try {
            service.delete(id);
        } catch (Exception e) {
            e.printStackTrace();
            js =new JsonResult("删除失败");
        }
        return js;
    }


    @RequiresPermissions("recruitDetail:queryById")
    @PermissionName("招聘计划详细列表单个查询")
    @RequestMapping("queryById")
    @ResponseBody
    public PageResult queryById(ApplicantQueryObject qo,Long id) {

        return  service.queryById(qo,id);
    }



}
